﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Select_Adapter
{
    class Program
    {
        static void Main(string[] args)
        {
            SqlConnection conn = new SqlConnection("Data Source=(local);Initial Catalog=sale; User Id=sa; Password=sa");
            SqlDataAdapter adapter = new SqlDataAdapter("select ID, Name from customers", conn);
            DataSet ds = new DataSet();
            adapter.Fill(ds, "customers");
            Console.WriteLine("So nhan vien : {0}", ds.Tables["customers"].Rows.Count);
            DataRow row = ds.Tables["customers"].NewRow();
            row["ID"] = "3";
            row["Name"] = "Nguyen Van C";
            ds.Tables["customers"].Rows.Add(row);
            Console.WriteLine("So nhan vien : {0}", ds.Tables["customers"].Rows.Count);
            adapter.Update(ds, "customers");
            conn.Close();              
        }
    }
}
